package 牛客周赛.牛客周赛Round39;

import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

/**
 * @Title: D正确的做法
 * @Author 贾金博
 * @Package 牛客周赛.牛客周赛Round39
 * @Date 2024/4/9 18:14
 * @description:
 */
public class D正确的做法 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int[] a = new int[n];
        int[] ret = new int[p];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() % p;
        }

        ArrayDeque<Pair> q = new ArrayDeque<>(); // 也是队列
        q.addLast(new Pair(0, 0)); // 初始的时候 什么都没有
        while(!q.isEmpty()) {
            Pair pair = q.removeFirst();
            int cnt = pair.getX() + 1;
            int now = pair.getY();
            for(int i = 0; i < n; ++ i ) {
                //注意下标越界的问题
                int y = (now + a[i] + p) % p;
                if(ret[y] == 0) { // 如果要是不等于0的话 就是最小的了 不用在更新了
                    ret[y] = cnt;
                    //还要放入进去
                    q.addLast(new Pair(cnt, y));
                }
            }
            if(ret[0] != 0 ) {
                break;
            }
        }
        System.out.println(ret[0]);
    }
}

class Pair {
    int x;
    int y;


    public Pair() {
    }

    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    /**
     * 获取
     * @return x
     */
    public int getX() {
        return x;
    }

    /**
     * 设置
     * @param x
     */
    public void setX(int x) {
        this.x = x;
    }

    /**
     * 获取
     * @return y
     */
    public int getY() {
        return y;
    }

    /**
     * 设置
     * @param y
     */
    public void setY(int y) {
        this.y = y;
    }

    public String toString() {
        return "pair{x = " + x + ", y = " + y + "}";
    }
}
